﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using JCNT.Model.DB;
namespace JCNT.BLL.DB
{
	/// <summary>
	/// wp_Adm
	/// </summary>
	public partial class wp_Adm
	{
		private readonly JCNT.DAL.DB.wp_Adm dal=new JCNT.DAL.DB.wp_Adm();
		public wp_Adm()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(long ID)
		{
			return dal.Exists(ID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(JCNT.Model.DB.wp_Adm model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(JCNT.Model.DB.wp_Adm model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(long ID)
		{
			
			return dal.Delete(ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string IDlist )
		{
			return dal.DeleteList(IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public JCNT.Model.DB.wp_Adm GetModel(long ID)
		{
			
			return dal.GetModel(ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public JCNT.Model.DB.wp_Adm GetModelByCache(long ID)
		{
			
			string CacheKey = "wp_AdmModel-" + ID;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(ID);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (JCNT.Model.DB.wp_Adm)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<JCNT.Model.DB.wp_Adm> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<JCNT.Model.DB.wp_Adm> DataTableToList(DataTable dt)
		{
			List<JCNT.Model.DB.wp_Adm> modelList = new List<JCNT.Model.DB.wp_Adm>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				JCNT.Model.DB.wp_Adm model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new JCNT.Model.DB.wp_Adm();
					if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="")
					{
						model.ID=long.Parse(dt.Rows[n]["ID"].ToString());
					}
					if(dt.Rows[n]["Use"]!=null && dt.Rows[n]["Use"].ToString()!="")
					{
					model.Use=dt.Rows[n]["Use"].ToString();
					}
					if(dt.Rows[n]["Pas"]!=null && dt.Rows[n]["Pas"].ToString()!="")
					{
					model.Pas=dt.Rows[n]["Pas"].ToString();
					}
					if(dt.Rows[n]["Oth"]!=null && dt.Rows[n]["Oth"].ToString()!="")
					{
					model.Oth=dt.Rows[n]["Oth"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

